package com.qcheng.diangpingclient;

import java.util.Timer;
import java.util.TimerTask;

import com.example.diangpingclient.R;
import com.qcheng.shareprefence.ShareUtils;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;

/**
 * 延时跳转可以使用hander
 * 
 * @author 伊斯坦堡
 * 
 */
public class WelcomeStarAct extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.welcome);
		/*
		 * new Handler(new Handler.Callback() {
		 * 
		 * @Override public boolean handleMessage(Message msg) { // 处理接收到消息的方法
		 * startActivity(new Intent(getApplicationContext(),
		 * MainActivity.class)); return false; } }).sendEmptyMessageDelayed(0,
		 * 3000);
		 */

		// 使用java定时器延时
		Timer timer = new Timer();
		timer.schedule(new Task(), 3000);// 定时器执行任务的方法

	}

	/**
	 * 定时器要执行的任务
	 * 
	 * @author 伊斯坦堡
	 * 
	 */
	class Task extends TimerTask {

		@Override
		public void run() {
			if (ShareUtils.getWelcomeBoolean(getBaseContext())) {
				startActivity(new Intent(getApplicationContext(),
						MainActivity.class));
			} else {
				// 实现页面的跳转
				startActivity(new Intent(getApplicationContext(),
						WelconGuideAct.class));
				ShareUtils.putWelcomeBoolean(getBaseContext(), true);
			}

		}
	}
}
